<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div {
            border: 1px solid;
            padding: 10px;
            width: 50%;
        }
    </style>
</head>

<body>
    <script src="../node_modules/vue/dist/vue.js"></script>

    <div id="app">
        <div @click='test()'>
            <p>{{hello}}</p>
            <!--  阻止冒泡事件，由里往外冒泡 -->
            <div v-on:click.stop='test()'>
                <p>小div</p>
                <!-- 阻止默认事件执行，例如a标签的跳转 -->
                <a href="http://www.baidu.com" target="_self" @click.prevent.stop='prevent()'>跳转</a>
            </div>
    
            
        </div>

        <input type="text" v-model='num' v-on:keyup.up='num++' v-on:keyup.down='num--' />
    </div>
    

    <script>
        new Vue({
            el: '#app',
            data: {
                hello: '你好，师姐！',
                num: 0
            },
            methods: {
                test() {
                    alert('落花')
                },
                prevent() {
                    alert('不让跳转...')
                }
            }
        })
    </script>
</body>

</html>